from django import forms


class LoginForm(forms.Form):
    # 用户名字段
    username = forms.CharField(
        widget=forms.TextInput(attrs={"placeholder": "用户名", "class": "form-control"}),
        required=True,  # required参数表示必须填写,验证时会验证不为空,
        min_length=3,
        max_length=16,  # min_length, max_length 都是用来验证最小和最大长度.
        error_messages={"required": "必须输入用户名",
                        "min_length": "用户名太短",
                        "max_length": "用户名太长"})  # 当验证出错的时候,给出这里的提示信息.
    password = forms.CharField(
        widget=forms.PasswordInput(attrs={"placeholder": "密码", "class": "form-control"}),
        required=True,
        min_length=3,
        max_length=16,
        error_messages={"required": "必须输入密码",
                        "min_length": "密码太短",
                        "max_length": "密码太长"})
